package com.atguigu.springcloud.controller;

import com.atguigu.springcloud.entities.CommonResult;
import com.atguigu.springcloud.entities.Payment;
import com.atguigu.springcloud.service.PaymentService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RestController;

@RestController
@Slf4j
public class PaymentController {

    @Autowired
    private PaymentService paymentService;

    @GetMapping("/payment/get/{id}")
    public CommonResult<Payment> getPayment(@PathVariable("id") Long id){
        Payment payment= paymentService.getPaymentById(id);
        if (payment!=null){
            log.info("查询结果"+payment);
//            int i=10/0;
            CommonResult result = new CommonResult(200, "查询成功", payment);
            return result;

        }
        else{
            return new CommonResult(444,"没有对应记录,查询ID: "+id,null);
}
    }
}
